package commandPattern;

import composite.ObjectItem;

public class Scale implements Command  {
	private ObjectItem objectItem;
	public ObjectItem getObjectItem() { return objectItem; }
	public void setObjectItem(ObjectItem objectItem) { this.objectItem = objectItem; }

	double oldScaleX, oldScaleY;
	public void setOldScaleX(double oldScaleX) { this.oldScaleX = oldScaleX; }
	public void setOldScaleY(double oldScaleY) { this.oldScaleY = oldScaleY; }

	double newScaleX, newScaleY;

	public void execute() {
		newScaleX = objectItem.getScaleX();
		newScaleY = objectItem.getScaleY();
		objectItem.scale(newScaleX, newScaleY);
	}

	public void redo() {
		objectItem.scale(newScaleX, newScaleY);
	}

	public void undo() {
		objectItem.scale(oldScaleX, oldScaleY);
	}
				
	/** Return a clone of command in state before execution */
	public Scale clone(){
		Scale commandClone = new Scale();
		commandClone.setObjectItem(objectItem);
		commandClone.setOldScaleX(oldScaleX);
		commandClone.setOldScaleY(oldScaleY);
		return commandClone;
	}
}
